package com.cx.mall.demo.dao.impl;

import com.cx.mall.demo.dao.IUserInfoDao;
import com.cx.mall.demo.entity.UserInfo;
import com.cx.mall.jdbc.JdbcUtils;

import java.sql.SQLException;

public class UserInfoDaoImpl  {
    /*@Override
    public void insert(UserInfo entity) throws SQLException {
        String sql = "INSERT INTO `user_info` VALUES (?,?,?,?,?,?,?,?)";
        Object[] params = {
                entity.getId(),
                entity.getUsername(),
                entity.getPassword(),
                entity.getEmail(),
                entity.getNickName(),
                entity.getNote(),
                entity.getCreateTime(),
                entity.getStatus()
        };
        JdbcUtils.update(sql,params);

    }

    @Override
    public void updateById(UserInfo entity) throws SQLException {
        String sql = "UPDATE `user_info` SET username = ?,password = ?,email = ?,nick_name = ?,note = ?,create_time = ?,status = ? WHERE id = ?";
        Object[] params = {
                entity.getUsername(),
                entity.getPassword(),
                entity.getEmail(),
                entity.getNickName(),
                entity.getNote(),
                entity.getCreateTime(),
                entity.getStatus(),
                entity.getId()
        };
        JdbcUtils.update(sql,params);
        System.out.println("更新成功");
    }

    @Override
    public void deleteById(Long id) throws SQLException {
        String sql = "DELETE FROM `user_info` WHERE id = ?";
        JdbcUtils.update(sql,id);
        System.out.println("删除成功");
    }

    @Override
    public UserInfo selectById(Long id) throws Exception {
        String sql = "SELECT * FROM `user_info` WHERE id = ?";
        return JdbcUtils.queryBean(sql,UserInfo.class,id);
    }*/
}
